add version of restic to the Prometheus metrics#495
Conversation
WalkthroughThe changes introduce a new label, Changes
Sequence Diagram(s)sequenceDiagram
participant Caller
participant Metrics
participant Prometheus
Caller->>Metrics: NewMetrics(profile, group, version, resticversion, configLabels)
Metrics->>Prometheus: Register build_info gauge with labels (profile, group, version, resticversion, ...)
Metrics->>Prometheus: Set build_info gauge with resticversion value
Note ⚡️ AI Code Reviews for VS Code, Cursor, WindsurfCodeRabbit now has a plugin for VS Code, Cursor and Windsurf. This brings AI code reviews directly in the code editor. Each commit is reviewed immediately, finding bugs before the PR is raised. Seamless context handoff to your AI code agent ensures that you can easily incorporate review feedback. Note ⚡️ Faster reviews with cachingCodeRabbit now supports caching for code and dependencies, helping speed up reviews. This means quicker feedback, reduced wait times, and a smoother review experience overall. Cached data is encrypted and stored securely. This feature will be automatically enabled for all accounts on May 16th. To opt out, configure 📜 Recent review detailsConfiguration used: CodeRabbit UI 📒 Files selected for processing (3)
🚧 Files skipped from review as they are similar to previous changes (3)
✨ Finishing Touches
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
SupportNeed help? Create a ticket on our support page for assistance with any issues or questions. Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
There was a problem hiding this comment.
Actionable comments posted: 0
🧹 Nitpick comments (1)
monitor/prom/metrics_test.go (1)
13-13: Tests updated to match new function signatureAll test cases have been properly updated to include the additional empty string parameter for Restic version. This ensures the tests match the new function signature.
Consider adding a specific test case that verifies the Restic version is correctly included in the metrics output. This would provide stronger validation that the new functionality works as expected.
Also applies to: 24-24, 35-35
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (3)
monitor/prom/metrics.go(3 hunks)monitor/prom/metrics_test.go(3 hunks)run_profile.go(1 hunks)
🧰 Additional context used
🧬 Code Graph Analysis (2)
run_profile.go (1)
monitor/prom/metrics.go (1)
NewMetrics(32-72)
monitor/prom/metrics_test.go (1)
monitor/prom/metrics.go (1)
NewMetrics(32-72)
🔇 Additional comments (5)
monitor/prom/metrics.go (4)
22-22: LGTM: New label for tracking Restic versionThe addition of
resticVersionLabelis a good enhancement, allowing for tracking of both resticprofile and restic versions in Prometheus metrics. This will help users identify outdated installations as mentioned in the PR objectives.
32-32: Function signature updated to include Restic version parameterGood addition of the restic version parameter to the
NewMetricsfunction. The parameter name is clear and consistent with existing naming conventions.
50-50: New label added to metrics vectorThe Restic version label is correctly appended to the list of label keys for the
build_infoPrometheus gauge vector.
52-52: Restic version information correctly setThe implementation correctly sets the Restic version information in the Prometheus gauge. This will allow users to query and filter metrics based on Restic version.
run_profile.go (1)
196-196: Appropriate usage of Restic version in metrics creationThe modified call to
prom.NewMetricscorrectly passesctx.global.ResticVersionas the new parameter. This ensures the Restic version from the current context is properly included in Prometheus metrics.
|
@antondollmaier thanks for this PR 👍🏻 Does it make more sense to create a new metric called I'm asking because it shouldn't be difficult to add a new metric, if that makes things easier to query from prometheus |
|
Thanks for the input!
I initially failed to do so, but succeeded now. And yes, the The metrics now look like this: Is that okay for you as well? |
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## master #495 +/- ##
==========================================
+ Coverage 79.22% 79.33% +0.11%
==========================================
Files 133 134 +1
Lines 13204 13229 +25
==========================================
+ Hits 10460 10495 +35
+ Misses 2326 2316 -10
Partials 418 418
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
creativeprojects
left a comment
There was a problem hiding this comment.
Apart from the tiny comment about the leftover constant, it all looks good to me, thanks for the PR 👍🏻
Add the restic version as a new metric `restic_build_info`. This allows to track the versions of both restic and resticprofile: PromQL can be used to identify outdated installations. refs creativeprojects#485
|
Thanks 😉 |
43b6c84
into
creativeprojects:master
Add the restic version as a new label to the existing metric
resticprofile_build_info.This allows tracking the versions of both restic and resticprofile: PromQL can be used to identify outdated installations.
I'm not an experienced developer in Go, so there might be better ways to solve this.
Adding the new metric
restic_build_infofailed for unknown reasons (the metric didn't show up in the output file).refs #485